package com.sky.sky_server.controller.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sky.sky_common.result.Result;
import com.sky.sky_server.service.impl.CategoryServiceImpl;

import lombok.extern.slf4j.Slf4j;

@RestController("userCategoryController")
@RequestMapping("/user/category")
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryServiceImpl categoryServiceImpl;

    /**
     * 根据类型id查询分类
     */
@GetMapping(value = "/list", params = "type")
public Result listByType(@RequestParam Integer type) {
    log.info("根据类型查询分类，type={}", type);
    return Result.success(categoryServiceImpl.list(type));
}

@GetMapping("/list")
public Result listAll() {
    log.info("查询所有分类");
    return Result.success(categoryServiceImpl.list(null));
}

}
